home *** CD-ROM | disk | FTP | other *** search
/ Aminet 52 / Aminet 52 (2002)(GTI - Schatztruhe)[!][Dec 2002].iso / Aminet / util / moni / Scout-src.lha / netinclude / sys / time.h < prev    next >
C/C++ Source or Header  |  2002-09-16  |  3KB  |  113 lines

  1. #ifndef SYS_TIME_H
  2. #define SYS_TIME_H \
  3.        "$Id: time.h,v 1.1.1.1 2001/11/26 22:21:20 tboeckel Exp $"
  4. /*
  5.  *      System time
  6.  *
  7.  *      Copyright © 1994 AmiTCP/IP Group,
  8.  *                       Network Solutions Development, Inc.
  9.  *                       All rights reserved.
  10.  */
  11.  
  12. #ifndef DEVICES_TIMER_H
  13. #include <devices/timer.h>
  14. #endif
  15.  
  16. /* 
  17.  * struct timeval is defined in <devices/timer.h>.  It is similar to the
  18.  * struct timeval defined normally in sys/time.h, but the names of the
  19.  * fields are different and the values are unsigned long instead of
  20.  * long. Following code rename the fields so that the UNIX code
  21.  * works correctly. (tv_sec and tv_usec are signed!!)
  22.  */
  23.  
  24. struct compatible_timeval {
  25.   union {
  26.     long s_sec;
  27.     ULONG u_secs;
  28.   } mtv_sec;
  29.   union {
  30.     long s_usec;
  31.     ULONG u_micro;
  32.   } mtv_usec;
  33. };
  34.  
  35. #define timeval compatible_timeval
  36. #define tv_sec mtv_sec.s_sec
  37. #define tv_usec mtv_usec.s_usec
  38. #define tv_secs mtv_sec.u_secs
  39. #define tv_micro mtv_usec.u_micro
  40.  
  41. /*
  42.  * We must define the timerequest, because compatible_timeval is not 
  43.  * compatible with old timeval...
  44.  */
  45. struct compatible_timerequest {
  46.     struct IORequest tr_node;
  47.     struct timeval tr_time;
  48. };
  49. #define timerequest compatible_timerequest
  50.  
  51. #if __SASC
  52. #ifndef PROTO_TIMER_H
  53. #include <proto/timer.h>
  54. #endif
  55. #elif __GNUC__
  56. #ifndef INLINE_TIMER_H
  57. /*
  58.  * predefine TimerBase to Library to follow SASC convention.
  59.  */
  60. #define BASE_EXT_DECL
  61. #define BASE_EXT_DECL0 extern struct Library * TimerBase;
  62. #define BASE_NAME (struct Device *)TimerBase
  63. #include <inline/timer.h>
  64. #endif
  65. #else
  66. #include <clib/timer_protos.h>
  67. #endif
  68.  
  69. #ifndef KERNEL
  70. /*
  71.  * These are not used by AmiTCP/IP itself
  72.  */
  73.  
  74. /*
  75.  * Because of a name conflict with SAS/C time.h definition 'timezone' and
  76.  * BSD sys/time.h struct timezone, time.h must always be included first.
  77.  * (the struct timezone becomes actually struct __timezone, but this does
  78.  * not raise a problem at the source level).
  79.  */
  80. #if __SASC
  81. #include <time.h>
  82. #endif
  83.  
  84. struct timezone {
  85.     int    tz_minuteswest;    /* minutes west of Greenwich */
  86.     int    tz_dsttime;    /* type of dst correction */
  87. };
  88. #define    DST_NONE    0    /* not on dst */
  89. #define    DST_USA        1    /* USA style dst */
  90. #define    DST_AUST    2    /* Australian style dst */
  91. #define    DST_WET        3    /* Western European dst */
  92. #define    DST_MET        4    /* Middle European dst */
  93. #define    DST_EET        5    /* Eastern European dst */
  94. #define    DST_CAN        6    /* Canada */
  95.  
  96. /* defined in the net.lib */
  97. extern int gettimeofday(struct timeval *tp, struct timezone *tzp);
  98. #endif /* KERNEL */
  99.  
  100. /*
  101.  * Operations on timevals.
  102.  *
  103.  * NB: timercmp does not work for >= or <=.
  104.  */
  105. #define    timerisset(tvp)        ((tvp)->tv_sec || (tvp)->tv_usec)
  106. #define    timercmp(tvp, uvp, cmp)    \
  107.     ((tvp)->tv_sec cmp (uvp)->tv_sec || \
  108.      (tvp)->tv_sec == (uvp)->tv_sec && (tvp)->tv_usec cmp (uvp)->tv_usec)
  109. #define    timerclear(tvp)        (tvp)->tv_sec = (tvp)->tv_usec = 0
  110.  
  111. #endif /* !SYS_TIME_H */
  112.  
  113.